### Function Description

Query the job execution status based on the job instance ID (dedicated to the Blue Shield job execution plugin,
informally publicly available API)

### Request Parameters

#### Body params

| Fields                             | Type    | Required | Description                                                                                                                                                           |
|------------------------------------|---------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| bk_scope_type                      | string  | yes      | Resource scope type. Optional values: biz - Business，biz_set - Business Set                                                                                           |
| bk_scope_id                        | string  | yes      | Resource scope ID. Corresponds to bk_scope_type, which means business ID or business set ID                                                                           |
| bk_biz_id                          | long    | yes      | Deprecated. Business ID. This field has been deprecated and replaced by the field bk_scope_type+bk_scope_id                                                           |
| job_instance_id                    | long    | yes      | Job instance ID                                                                                                                                                       |
| include_execute_object_task_result | boolean | no       | Whether to return the task details on each execution object, corresponding to the step_execute_object_result_list in the returned result. The default value is false. |

### Example of request

- Body

```json
{
    "bk_scope_type": "biz",
    "bk_scope_id": "2",
    "job_instance_id": 100,
    "include_execute_object_task_result": true
}
```

### Example of responses

```json
{
    "result": true,
    "code": 0,
    "data": {
        "finished": true,
        "job_instance": {
            "job_instance_id": 100,
            "bk_scope_type": "biz",
            "bk_scope_id": "1",
            "name": "API Quick execution script1521089795887",
            "create_time": 1605064271000,
            "status": 4,
            "start_time": 1605064271000,
            "end_time": 1605064272000,
            "total_time": 1000
        },
        "step_instance_list": [
            {
                "status": 4,
                "total_time": 1000,
                "name": "API Quick execution scriptxxx",
                "step_instance_id": 75,
                "execute_count": 0,
                "create_time": 1605064271000,
                "end_time": 1605064272000,
                "type": 1,
                "start_time": 1605064271000,
                "execute_object_result_list": [
                    {
                        "execute_object": {
                            "type": 1,
                            "resource_id": "101",
                            "host": {
                                "bk_host_id": 101,
                                "ip": "127.0.0.1",
                                "bk_cloud_id": 0
                            }
                        },
                        "status": 9,
                        "tag": "",
                        "exit_code": 0,
                        "error_code": 0,
                        "start_time": 1605064271000,
                        "end_time": 1605064272000,
                        "total_time": 1000
                    }
                ]
            }
        ]
    },
    "job_request_id": "xxx"
}
```

### Response Description

{% include '_generic_response.md.j2' %}

##### data

| Fields             | Type   | Never null | Description                                                         |
|--------------------|--------|------------|---------------------------------------------------------------------|
| finished           | bool   | yes        | Has the homework been completed                                     |
| job_instance       | object | yes        | Basic information of homework instance. See job_instance definition |
| step_instance_list | array  | yes        | List of homework steps. See the definition of step_instance         |

##### job_instance

| Fields          | Type   | Never null | Description                                                                                                                                                                                                                          |
|-----------------|--------|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| name            | string | yes        | Job instance name                                                                                                                                                                                                                    |
| status          | int    | yes        | Job status code. 1 - Pending; 2 - Running 3 - Successful; 4 - Failed; 5 - Skipped; 6 - Ignore Error; 7 - Waiting; 8 - Terminated; 9 - Abnormal; 10 - Terminating; 11 - Terminate Success; 13 - Termination Confirmed; 14 - Abandoned |
| create_time     | long   | yes        | Job creation time, Unix timestamp, in milliseconds                                                                                                                                                                                   |
| start_time      | long   | no         | Execution start time, Unix timestamp, in milliseconds                                                                                                                                                                                |
| end_time        | long   | no         | Execution end time, Unix timestamp, in milliseconds                                                                                                                                                                                  |
| total_time      | int    | no         | Total elapsed time in milliseconds                                                                                                                                                                                                   |
| bk_scope_type   | string | yes        | Resource scope type. Optional values: biz - Business，biz_set - Business Set                                                                                                                                                          |
| bk_scope_id     | string | yes        | Resource scope ID. Corresponds to bk_scope_type, which means business ID or business set ID                                                                                                                                          |
| job_instance_id | long   | yes        | Job instance ID                                                                                                                                                                                                                      |

##### step_instance

| Fields              | Type   | Never null | Description                                                                                                                                                                                                                           |
|---------------------|--------|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| step_instance_id    | long   | yes        | Job step instance ID                                                                                                                                                                                                                  |
| type                | int    | yes        | Step Type: 1. Script step; 2. File step; 4. SQL step                                                                                                                                                                                  |
| name                | string | yes        | Step name                                                                                                                                                                                                                             |
| status              | int    | yes        | Step status code. 1 - Pending; 2 - Running 3 - Successful; 4 - Failed; 5 - Skipped; 6 - Ignore Error; 7 - Waiting; 8 - Terminated; 9 - Abnormal; 10 - Terminating; 11 - Terminate Success; 13 - Termination Confirmed; 14 - Abandoned |
| create_time         | long   | yes        | Job step instance creation time, Unix timestamp, in milliseconds                                                                                                                                                                      |
| start_time          | long   | no         | Execution start time, Unix timestamp, in milliseconds                                                                                                                                                                                 |
| end_time            | long   | no         | Execution end time, Unix timestamp, in milliseconds                                                                                                                                                                                   |
| total_time          | int    | no         | Total elapsed time in milliseconds                                                                                                                                                                                                    |
| execute_count       | int    | yes        | Step retry times                                                                                                                                                                                                                      |
| step_ip_result_list | array  | yes        | See step_ip_result for the task execution result of each host                                                                                                                                                                         |

##### execute_object_result

| Fields         | Type   | Never null | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|----------------|--------|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| execute_object | object | yes        | Execute object, as defined in Execute_Object                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| status         | int    | yes        | Job execution status: 1. Agent exception; 5. Waiting for execution; 7. In progress; 9. Successful execution; 11. Execution failed; 12. Task issuance failed; 403. Task forced termination successful; 404. Task forced termination failed                                                                                                                                                                                                                                                                                                                                                                          |
| tag            | string | no         | The user customizes the output results through the job_Success/job_fail function template. Only script tasks have this parameter present                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| exit_code      | int    | no         | Script task exit code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| error_code     | int    | yes        | Host task status code, 1. Agent exception; 3. Last time it was successful; 5. Waiting for execution; 7. In progress; 9. Successful execution; 11. Task failure; 12. Task issuance failed; 13. Task timeout; 15. Task log error; 101. Script execution failed; 102. Script execution timed out; 103. Script execution terminated; 104. The script return code is non-zero; 202. File transfer failed; 203. The source file does not exist; 310. Agent exception; 311. The username does not exist; 320. File retrieval failed; 321. The file exceeds the limit; 329. File transfer error; 399. Task execution error |
| start_time     | long   | no         | Execution start time, Unix timestamp, in milliseconds                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| end_time       | long   | no         | Execution end time, Unix timestamp, in milliseconds                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| total_time     | int    | no         | Total elapsed time in milliseconds                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

##### execute_object

| Fields      | Type   | Never null | Description                                                                               |
|-------------|--------|------------|-------------------------------------------------------------------------------------------|
| type        | int    | yes        | Execution object type, 1- Host, 2- Container                                              |
| resource_id | string | yes        | Execute object resource ID (e.g. the resource ID corresponding to the host is bk_host_id) |
| host        | object | no         | Host details, defined as host                                                             |
| container   | object | no         | Container details, defined in container                                                   |

##### host

| Fields      | Type   | Never null | Description    |
|-------------|--------|------------|----------------|
| bk_host_id  | long   | yes        | Host ID (cmdb) |
| bk_cloud_id | long   | yes        | Cloud ID       |
| ip          | string | yes        | Ipv4           |

##### container

| Fields        | Type   | Never null | Description                                     |
|---------------|--------|------------|-------------------------------------------------|
| id            | long   | yes        | Container ID (cmdb)                             |
| container_uid | string | yes        | Unique ID (UID) of the container in the cluster |
| name          | string | yes        | Container name                                  |
